<template>
  <div>
    <FilterTable
      ref="table"
      height="auto"
      columnsRef="partPartOutboundPartSalesCheckStock"
      :columns="columns"
      :datakey="'rows'"
      :onColumnsChange="columns => (this.columns = columns)"
      :isSelectColumn="false"
      :isPagination="true"
    ></FilterTable>
    <div>
      <div>是否负库存：上述配件出入库会造成负库存，是否入账？是否库存或金额为零;</div>
      <div>1.库存数量*成本单价()成本金额且库存数量或成本金额有为零；</div>
      <div>2.成本单价为零。</div>
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">取消</el-button>
      <el-button type="primary" @click="closeDrawer(2)">确定</el-button>
    </div>
  </div>
</template>
<script>
import { partSalesIfBear } from '@/api/part/partOut/partSales/index';
import { dictionary } from '@/utils/dictMixin';
import { debuglog } from 'util';
export default {
  name: 'checkStock',
  mixins: [dictionary],
  props: ['checkData'],

  data() {
    this.BaseTable = null;
    return {
      syncColumns: [],
      columns: this.createTablelist(),
      selectedRows: [],
      loading: false,
      fromSubmitdata: {}
    };
  },

  mounted() {
    console.log(this.checkData, '父页面查询的数据');
    this.BaseTable = this.$refs.table.$refs.pageTable;
    this.init();
  },
  methods: {
    init() {
      this.BaseTable.EXECUTE_INSERT(this.checkData);
    },

    async closeDrawer(type) {
      if (type == 1) {
        this.$emit('close', false);
      } else {
        this.checkData.forEach(x => {
          if (x.IS_NEGATIVE == 10041002) {
            return this.$notify.error({ title: '提示信息', message: '有不允许负库存的明细' });
          }
          this.$emit('saveDialog', this.checkData);
        });
      }
    },
    createTablelist() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '仓库',
          dataIndex: 'STORAGE_CODE',
          sorter: true,
          filter: true
        },
        {
          title: '配件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true
        },
        {
          title: '配件名称',
          dataIndex: 'PART_NAME',
          sorter: true,
          filter: true
        },
        {
          title: '是否库存或金额为零',
          dataIndex: 'ISNORMAL',
          sorter: true,
          filter: true,
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.ISNORMAL, '1004')}</span>;
          }
        },
        {
          title: '是否负库存',
          dataIndex: 'ISNEGATIVE',
          sorter: true,
          filter: true,
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.ISNEGATIVE, '1004')}</span>;
          }
        },
        {
          title: '可用库存',
          dataIndex: 'USEABLE_STOCK',
          sorter: true,
          filter: true
        },
        {
          title: '出库数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true
        },
        {
          title: '锁定数量',
          dataIndex: 'LOCKED_QUANTITY',
          sorter: true,
          filter: true
        },
        {
          title: '是否允许负库存',
          dataIndex: 'IS_NEGATIVE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_NEGATIVE, '1004')}</span>;
          }
        }
      ];
    }
  }
};
</script>
